package server;

import java.io.*;
import java.net.*;

import common.ServerInterface;


public class SocketServer implements ServerInterface{
	
	
	public void start(int port) {
		try{
			Gioco.getInstance().getMappa().inizializzaMappa();
			ServerSocket serverSocket= new ServerSocket(port);
			
			while(true){
				System.out.println("in attesa su " + port);
				Socket socket= serverSocket.accept();
				System.out.println("ricevuta connessione: " + socket.getInetAddress() + ":" + socket.getPort());
				(new SocketClientHandler(socket)).start();
			}
		}
		catch(IOException e) {
			e.printStackTrace();
		}
		
	}
}
